<?php

/**
 * This is the model class for table "administrasi_detail".
 *
 * The followings are the available columns in table 'administrasi_detail':
 * @property string $id
 * @property string $checklist_admin_id
 * @property string $nomor
 * @property string $tanggal_surat
 * @property string $tanggal_terdaftar
 * @property string $tanggal_ditetapkan
 * @property string $berlaku_sampai
 * @property string $nama_pejabat
 * @property string $instansi_pemberi
 * @property string $kualifikasi_perusahaan
 * @property string $kegiatan_usaha_pokok
 * @property string $kbli
 * @property string $klasifikasi
 * @property string $pemberi_izin
 * @property string $perihal
 * @property string $lokasi
 * @property string $luas
 * @property string $pengesahan_kemenkumham
 * @property string $upload_dokumen
 *
 * The followings are the available model relations:
 * @property ChecklistAdmin $checklistAdmin
 */
class AdministrasiDetail extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'administrasi_detail';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('checklist_admin_id', 'required'),
			array('checklist_admin_id', 'length', 'max'=>11),
			array('nomor, nama_pejabat, kbli, pemberi_izin, lokasi', 'length', 'max'=>50),
			array('instansi_pemberi', 'length', 'max'=>60),
			array('kualifikasi_perusahaan', 'length', 'max'=>9),
			array('kegiatan_usaha_pokok', 'length', 'max'=>100),
			array('klasifikasi', 'length', 'max'=>25),
			array('perihal, pengesahan_kemenkumham', 'length', 'max'=>30),
			array('luas', 'length', 'max'=>10),
			array('tanggal_surat, tanggal_terdaftar, tanggal_ditetapkan, berlaku_sampai', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, checklist_admin_id, nomor, tanggal_surat, tanggal_terdaftar, tanggal_ditetapkan, berlaku_sampai, nama_pejabat, instansi_pemberi, kualifikasi_perusahaan, kegiatan_usaha_pokok, kbli, klasifikasi, pemberi_izin, perihal, lokasi, luas, pengesahan_kemenkumham', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'checklistAdmin' => array(self::BELONGS_TO, 'ChecklistAdmin', 'checklist_admin_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'checklist_admin_id' => 'Checklist Admin',
			'nomor' => 'Nomor',
			'tanggal_surat' => 'Tanggal Surat',
			'tanggal_terdaftar' => 'Tanggal Terdaftar',
			'tanggal_ditetapkan' => 'Tanggal Ditetapkan',
			'berlaku_sampai' => 'Berlaku Sampai',
			'nama_pejabat' => 'Nama Pejabat',
			'instansi_pemberi' => 'Instansi Pemberi',
			'kualifikasi_perusahaan' => 'Kualifikasi Perusahaan',
			'kegiatan_usaha_pokok' => 'Kegiatan Usaha Pokok',
			'kbli' => 'Kbli',
			'klasifikasi' => 'Klasifikasi',
			'pemberi_izin' => 'Pemberi Izin',
			'perihal' => 'Perihal',
			'lokasi' => 'Lokasi',
			'luas' => 'Luas',
			'pengesahan_kemenkumham' => 'Pengesahan Kemenkumham',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('checklist_admin_id',$this->checklist_admin_id,true);
		$criteria->compare('nomor',$this->nomor,true);
		$criteria->compare('tanggal_surat',$this->tanggal_surat,true);
		$criteria->compare('tanggal_terdaftar',$this->tanggal_terdaftar,true);
		$criteria->compare('tanggal_ditetapkan',$this->tanggal_ditetapkan,true);
		$criteria->compare('berlaku_sampai',$this->berlaku_sampai,true);
		$criteria->compare('nama_pejabat',$this->nama_pejabat,true);
		$criteria->compare('instansi_pemberi',$this->instansi_pemberi,true);
		$criteria->compare('kualifikasi_perusahaan',$this->kualifikasi_perusahaan,true);
		$criteria->compare('kegiatan_usaha_pokok',$this->kegiatan_usaha_pokok,true);
		$criteria->compare('kbli',$this->kbli,true);
		$criteria->compare('klasifikasi',$this->klasifikasi,true);
		$criteria->compare('pemberi_izin',$this->pemberi_izin,true);
		$criteria->compare('perihal',$this->perihal,true);
		$criteria->compare('lokasi',$this->lokasi,true);
		$criteria->compare('luas',$this->luas,true);
		$criteria->compare('pengesahan_kemenkumham',$this->pengesahan_kemenkumham,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return AdministrasiDetail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
